#include using namespace std; //return the number of char's before the \0 int stringLength(char s[]); //return true if they have all the same char's before the \0 bool sameString(char s1[], char s2[]); //assume that the source is a valid c-style string //assume that the destination is big enough to hold the source void copyString(char destination[], char source[]); //append, concatenate void appendString(char destination[], char source[]); //return true if s has the character query bool contains(char s[], char query); //return true if s has the string query bool contains(char s[], char query[]); void reverse(char s[]); int occurances(char s[], char query); bool isStrongPassword(char password[]); void main() { //char s1[100]; //cin >> s1; //cout << stringLength(s1) << endl; //char s2[100]; ////s2 = s1; // bad ////copyString(s2, s1); //if(contains(s1,"on")) //{ // cout << "found it" << endl; //} //cout << occurances("ljalksdjfkljashdfkljhasndklhnskcthkasvunhdtckasdhtkv", 'v') << endl; char password[80]; do { cin>> password; if(isStrongPassword(password)) { cout << password << " is strong" << endl; } else { cout << password << " is weak" << endl; } } while(strnicmp(password,"quit",3) != 0); //char s[1000]; //cin.getline(s,1000); //cout << strlen(s) << endl; //char s2[1000]; //strcpy(s2,s + 2); //cout << s2 << endl; //strcat(s2,"yay"); //cout << s2 << endl; } bool containsDigit(char s[]) { bool result = false; for(int i = 0; s[i] != '\0'; i++) { if(s[i] >= '0' && s[i]<= '9') { result = true; } } return result; } bool containsUpperCaseLetter(char s[]) { bool result = false; for(int i = 0; s[i] != '\0'; i++) { if(s[i] >= 'A' && s[i]<= 'Z') { result = true; } } return result; } bool containsLowerCaseLetter(char s[]) { bool result = false; for(int i = 0; s[i] != '\0'; i++) { if(s[i] >= 'a' && s[i]<= 'z') { result = true; } } return result; } bool containsSpecialChar(char s[]) { bool result = false; for(int i = 0; s[i] != '\0'; i++) { //see ASCII table if((s[i] >= 33 && s[i]<= 47) || (s[i] >= 58 && s[i]<= 64) || (s[i] >= 91 && s[i]<= 96) || (s[i] >= 123 && s[i]<= 126)) { result = true; } } return result; } bool isStrongPassword(char password[]) { bool result = true; if(!containsDigit(password) || !containsSpecialChar(password) || !containsUpperCaseLetter(password) || !containsLowerCaseLetter(password) || stringLength(password) < 10) { result = false; } return result; } int stringLength(char s[]) { int i = 0; while(s[i] != '\0') { i++; } return i; } int occurances(char s[], char query) { int result = 0; for(int i = 0;s[i] != '\0';i++) { if(s[i] == query) { result++; } } return result; } bool contains(char s[], char query) { bool foundQuery = false; for(int i = 0;s[i] != '\0' && !foundQuery;i++) { if(s[i] == query) { foundQuery = true; } } return foundQuery; } bool contains(char s[], char query[], int startIndex) { bool result = true; int queryLength =stringLength(query); int queryIndex = 0; for(int i = startIndex; i < startIndex + queryLength; i++, queryIndex++) { if(s[i] != query[queryIndex]) { result = false; } } return result; } bool contains(char s[], char query[]) { bool foundQuery = false; int length = stringLength(s) - stringLength(query) + 1; for(int i = 0;i < length && !foundQuery;i++) { if(contains(s,query,i)) { foundQuery = true; } } return foundQuery; }